/**
 * 点击选择图片按钮
 */
$('#ImgUpLoad').click(function(e) {
	_this = $(this);
	// 点击file文件
	$('#uploadImage').click();
});

/**
 * 点击确定添加图片
 */
$("#add").click(
		function(e) {

			var image_src = $("#add_content").find("img").attr("src");

			var category_name = $("#categoryName").val();
			if (category_name == null || category_name == ""
					|| category_name == undefined) {
				alert("分类名不能为空");
			} else {

				var url = base_url + "admin/addcategory";
				var params = {
					"productCategoryName" : category_name,
					"productCategoryUrl" : null
				}
				post(url, params);

			}
		});

/**
 * 删除轮播图
 */
function del(obj) {

	// 获取到轮播图的id
	var id = $(obj).parent().parent()[0].id;
	var url = base_url + "admin/hideOrshowCategory";
	var params = {
		"id" : id
	}
	post(url, params);
}

/**
 * 修改轮播图
 * 
 * @param id
 *            轮播图id
 */
function update(id) {

	var image_src = $("#changeImg_content").find("img").attr("src");
	var priority = $("#priority").attr("value");

	var category_name = $("#updateText").val();
	if (category_name == null || category_name == ""
			|| category_name == undefined) {
		alert("分类不能为空");
	} else {
		var url = base_url + "admin/updateCategory";
		var params = {
			"productCategoryId" : id,
			"productCategoryName" : category_name,
			"productCategoryUrl" : image_src
		}
		post(url, params);

	}

}
/**
 * 上改次序
 */
$(".up").click(function(e) {

	// 获取到轮播图的id
	var firstId = $(this).parents("tr").attr("id");
	var secondId = $(this).parents("tr").prev().attr("id");
	var url = base_url + "admin/changeOrder";
	var params = {
		"firstId" : firstId,
		"secondId" : secondId
	}
	post(url, params);
});
/**
 * 下改次序
 */
$(".down").click(function(e) {

	// 获取到轮播图的id
	var firstId = $(this).parents("tr").attr("id");
	var secondId = $(this).parents("tr").next().attr("id");
	var url = base_url + "admin/changeOrder";
	var params = {
		"firstId" : firstId,
		"secondId" : secondId
	}
	post(url, params);
});


// 删除分类
$(".deleteCategoryJiLian").click(function(e) {

	var id = $(this).parents("tr").attr("id");
	var params = {
		"id" : id
	}
	var url = base_url + "admin/deleteCategory";
	post(url, params);
})
